﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMeterParamFrame.Model.DIValueConverters
{
    class Converter_DateTime : IDIDataConverter
    {
        public bool CanConverter(string di)
        {
            return di.Equals("04000102");
        }

        public string ConvertToUI(string di, string value)
        {
            string newValue = value.Substring(0, 2) + "-" +
                value.Substring(2, 2) + "-" +
                value.Substring(4, 2);
            return newValue;
        }

        public string ConvertToLow(string di, string value)
        {
            string[] values = value.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
            string newValue = "";
            for (int i = 0; i < values.Length; i++)
            {
                newValue += values[i].PadLeft(2, '0');
            }
            return newValue;
        }

        public bool ValidateValue(string di, string value)
        {
            throw new NotImplementedException();
        }
    }
}
